package no.ntnu.fp.gui.calendar;

import java.awt.Font;
import java.awt.event.ActionListener;
import java.util.Calendar;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class SelectWeekPanel extends JPanel {
	private JLabel weekLabel;
	private JButton previousWeek, nextWeek;
	private ImageIcon left;
	private ImageIcon right;
	
	private final Calendar calendar;
	
	public SelectWeekPanel(Calendar calendar){
		this.calendar = calendar;
		
		left = new ImageIcon("images/changeLeft4.png");
		right = new ImageIcon("images/changeRight4.png");
		
		weekLabel = new JLabel("Uke: ");
		weekLabel.setFont(new Font("Tahoma", Font.BOLD, 20));
		previousWeek = new JButton(left);
		nextWeek = new JButton(right);
		add(previousWeek);
		add(weekLabel);
		add(nextWeek);
		
		updateDate();
	}
	public void updateDate(){
		weekLabel.setText(String.format("Uke: %02d", getWeek()));
	}
	public void setNextWeekActionListener(ActionListener ac){
		nextWeek.addActionListener(ac);
	}
	public void setPrevoiusWeekActionListener(ActionListener ac){
		previousWeek.addActionListener(ac);
	}

	private int getWeek() {
		return calendar.get(Calendar.WEEK_OF_YEAR);
	}
	
}
